#include "modelScene.h"

ModelScene::ModelScene()
{
	if (nullptr == m_Camera)
	{
		m_Camera = new Camera3D();
	}

	if (nullptr == m_RootObj)
	{
		m_RootObj = new SceneObj(nullptr, nullptr, "Root Obj");
		if (nullptr == m_SelectedObj)
		{
			m_SelectedObj = new SceneObj(nullptr, new SW::ModelSprite(), "ModelSprite");
		}
		m_RootObj->PushChild(m_SelectedObj);
	}
}

ModelScene::~ModelScene()
{
	if (m_Camera)
	{
		delete m_Camera;
		m_Camera = nullptr;
	}

	if (m_RootObj)
	{
		delete m_RootObj;
		m_RootObj = nullptr;
	}
}

void ModelScene::Update(float deltaTime)
{
	if (m_Camera)
	{
		m_Camera->Update(deltaTime);
	}	
}

void ModelScene::Render()
{
	SW::Renderer::SetCurrentCamera(m_Camera);

	if (m_RootObj)
	{
		m_RootObj->Render();
	}
}

void ModelScene::RenderSwGui()
{
	/*SW::Begin("options");

	bool useColor = ((DemoSprite*)m_SelectedObj->GetSprite())->GetUseColor();
	if (SW::Checkbox("UseColor", &useColor))
	{
		((DemoSprite*)m_SelectedObj->GetSprite())->SetUseColor(useColor);
	}

	bool useUV = ((DemoSprite*)m_SelectedObj->GetSprite())->GetUseUV();
	if (SW::Checkbox("UseUV", &useUV))
	{
		((DemoSprite*)m_SelectedObj->GetSprite())->SetUseUV(useUV);
	}

	SW::End();*/
}